﻿using System.Runtime.CompilerServices;

List<Data> list = new List<Data>();
for(int i=0; i < 10; i++)
{
    list.Add(new Data()
    {
        Id= i,
        Name=$"张{i}",
        DateTime = DateTime.Now.AddMinutes(i),
        Description="test"
    });
}

//list=list.Where(t => t.Id > 5).ToList();
list = list.MyFind(t => t.Id > 5);
Console.WriteLine(list.Count);

static class MyMethods
{
    public static List<T> MyFind<T>(this List<T> list,MyFindHandler<T> handler)
    {
        if (handler == null)
        {
            throw new ArgumentNullException("MyFindHandler 必须定义");
        }
        List<T> newList=new List<T>();
        foreach (var item in list)
        {
            if (handler(item))
            {
                newList.Add(item);
            }
        }
        return newList;
    }
}

delegate bool MyFindHandler<T>(T obj);


class Data
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public DateTime DateTime { get; set; }
}